﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProgLab.CalendarSyncUtil;
using Google.GData.Calendar;

namespace ProgLab.CalendarSync
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        protected void LoadGoogle()
        {            
        }

        protected void LoadOutlook()
        {
        }

        protected void Compare()
        {
        }

        private void btnRefreshGoogleCalendar_Click(object sender, EventArgs e)
        {
            this.btnRefreshGoogleCalendar.Enabled = false;

            this.lvGoogleCalendar.Items.Clear();

            GoogleCalendarSource calSourceGoogle = new GoogleCalendarSource();

            calSourceGoogle.User = this.textUserName.Text.Trim();
            calSourceGoogle.Password = this.textPassword.Text.Trim(); 

            List<CalendarEntry> listCalendar = calSourceGoogle.QueryAllCalendar();
            foreach (CalendarEntry entryCal in listCalendar)
            {
                //System.Diagnostics.Trace.WriteLine("TITLE:" + entryCal.Title.Text + ",Summary:" + entryCal.Summary.Text);
                ListViewItem lvItem = new ListViewItem(entryCal.Title.Text);
                lvItem.SubItems.Add(entryCal.Summary.Text);

                this.lvGoogleCalendar.Items.Add(lvItem);
            }

            this.btnRefreshGoogleCalendar.Enabled = true;
        }
    }
}
